﻿using UnityEngine;
using System.Collections;

public class KeyboardController : MonoBehaviour, IInputController {

	private Vector2 movementDirection;

	// Use this for initialization
	void Start () {
		movementDirection = new Vector2(0f, 0f);
	}
	
	// Update is called once per frame
	void Update () {
	
	}

	//IInput Controller Interface Methdos
	public Vector2 GetMovementDirection()
	{
		if (Input.GetKey("left"))
		{
			movementDirection.x = -1;
		}

		if (Input.GetKey("right"))
		{
			movementDirection.x = 1;
		}

		if (!Input.GetKey("left") && !Input.GetKey("right"))
		{
			movementDirection.x = 0;
		}
	
		if (Input.GetKey("up"))
		{
			movementDirection.y = 1;
		}

		if (Input.GetKey("down"))
		{
			movementDirection.y = -1;
		}

		if (!Input.GetKey("up") && !Input.GetKey("down"))
		{
			movementDirection.y = 0;
		}


		return movementDirection;
	}

	public bool ActionButtonDown() {
		return Input.GetKeyDown(KeyCode.A);
	}

	public bool SecondaryActionButtonDown() {
		return Input.GetKeyDown(KeyCode.X);
	}

	public bool CancelButtonDown() {
		return Input.GetKeyDown(KeyCode.S);
	}

	public bool NavigateMenuUp() {
		return Input.GetKeyDown("up");
	}

	public bool NavigateMenuDown() {
		return Input.GetKeyDown("down");
	}

	public bool JumpButtonDown() 
	{
		return Input.GetKeyDown(KeyCode.Space);
	}

	//testing for crouching action
	public bool CrouchButtonPressed()
	{
		return Input.GetKey(KeyCode.LeftControl);;
	}

	public bool CrouchButtonDown()
	{
		return Input.GetKeyDown(KeyCode.LeftControl);;
	}
	
	public bool FireButtonPressed()
	{
		return Input.GetKey("left ctrl");
	}

	public bool FireButtonDown()
	{
		return Input.GetKeyDown("left ctrl");
	}

	public bool SwapWeaponPressed()
	{
		return Input.GetKeyDown("left alt");
	}
}
